/*
 * 类名称:RegionRelateBedroomController.java
 * 包名称:com.platform.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-08-28 15:14:28        lipengjun     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.annotation.SysLog;
import com.platform.entity.SysMenuEntity;
import com.platform.utils.PageUtils;
import com.platform.utils.R;
import com.platform.controller.AbstractController;
import com.platform.entity.RegionRelateBedroomEntity;
import com.platform.service.RegionRelateBedroomService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 区域学校寝室楼关联表Controller
 *
 * @author sunkaichun
 * @date 2019-08-28 15:14:28
 */
@RestController
@RequestMapping("regionrelatebedroom")
public class RegionRelateBedroomController extends AbstractController {
    @Autowired
    private RegionRelateBedroomService regionRelateBedroomService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return R
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("regionrelatebedroom:list")
    public R queryAll(@RequestParam Map<String, Object> params) {
        List<RegionRelateBedroomEntity> list = regionRelateBedroomService.queryAll(params);
        return R.ok().put("list", list);
    }
    /**
     * 查看所有列表
     *
     * @return R
     */
    @RequestMapping("/queryAllSchool")
    @RequiresPermissions("regionrelatebedroom:list")
    public R queryAllSchool() {
        List<RegionRelateBedroomEntity> list = regionRelateBedroomService.queryAllSchool();
        return R.ok().put("list", list);
    }
    /**
     * 查看所有列表
     *
     * @return R
     */
    @RequestMapping("/queryAllDorm")
    @RequiresPermissions("regionrelatebedroom:list")
    public R queryAllDorm() {
        List<RegionRelateBedroomEntity> list = regionRelateBedroomService.queryAllDorm();
        return R.ok().put("list", list);
    }



    /**
     * 分页查询区域学校寝室楼关联表
     *
     * @param params 查询参数
     * @return R
     */
    @GetMapping("/list")
    @RequiresPermissions("regionrelatebedroom:list")
    public R list(@RequestParam Map<String, Object> params) {
        Page page = regionRelateBedroomService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return R
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("regionrelatebedroom:info")
    public R info(@PathVariable("id") Integer id) {
        RegionRelateBedroomEntity regionRelateBedroom = regionRelateBedroomService.getById(id);

        return R.ok().put("regionrelatebedroom", regionRelateBedroom);
    }

    /**
     * 新增区域学校寝室楼关联表
     *
     * @param regionRelateBedroom regionRelateBedroom
     * @return R
     */
    @SysLog("新增区域学校寝室楼关联表")
    @RequestMapping("/save")
    @RequiresPermissions("regionrelatebedroom:save")
    public R save(@RequestBody RegionRelateBedroomEntity regionRelateBedroom) {

        regionRelateBedroomService.add(regionRelateBedroom);

        return R.ok();
    }

    /**
     * 修改区域学校寝室楼关联表
     *
     * @param regionRelateBedroom regionRelateBedroom
     * @return R
     */
    @SysLog("修改区域学校寝室楼关联表")
    @RequestMapping("/update")
    @RequiresPermissions("regionrelatebedroom:update")
    public R update(@RequestBody RegionRelateBedroomEntity regionRelateBedroom) {

        regionRelateBedroomService.update(regionRelateBedroom);

        return R.ok();
    }

    /**
     * 根据主键删除区域学校寝室楼关联表
     *
     * @param ids ids
     * @return R
     */
    @SysLog("删除区域学校寝室楼关联表")
    @RequestMapping("/delete")
    @RequiresPermissions("regionrelatebedroom:delete")
    public R delete(@RequestBody Integer[] ids) {
        regionRelateBedroomService.deleteBatch(ids);

        return R.ok();
    }


    /**
     * 选择树(添加、修改)
     */
    @RequestMapping("/select")
    @RequiresPermissions("regionrelatebedroom:select")
    public R select() {
        //查询列表数据
        List<RegionRelateBedroomEntity> bedroomEntities = regionRelateBedroomService.queryNotBedRoomList();

        //添加顶级菜单
        RegionRelateBedroomEntity root = new RegionRelateBedroomEntity();
        root.setId(0);
        root.setName("城市");
        root.setParentId(0);
        bedroomEntities.add(root);

        return R.ok().put("bedroomEntities", bedroomEntities);
    }
}
